package org.bedracket.bedracketenchantment.init;

import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.bedracket.bedracketenchantment.BREMod;
import org.bedracket.bedracketenchantment.enchantment.*;

import java.util.function.Supplier;

public class ModEnchantments {

    public static final DeferredRegister<Enchantment> ENCHANTMENTS =
            DeferredRegister.create(ForgeRegistries.ENCHANTMENTS,
                    BREMod.MOD_ID);

    public static final RegistryObject<Enchantment> VAMPIRISM = register("vamprisim",
            VampirismEnchantment::new);

    public static final RegistryObject<Enchantment> RANDOMIZATION = register("randomization",
            RandomizationEnchantment::new);

    public static final RegistryObject<Enchantment> POISONOUS = register("poisonous",
            PoisonousEnchantment::new);

    public static final RegistryObject<Enchantment> EXPANSION = register("expansion",
            ExpansionEnchantment::new);

    public static final RegistryObject<Enchantment> CURSE_PAIN = register("curse_pain",
            CursePainEnchantment::new);

    public static final RegistryObject<Enchantment> BEHEADING = register("beheading",
            BeheadingEnchantment::new);

    public static final RegistryObject<Enchantment> SLOWDOWN = register("slowdown",
            SlowDownEnchantment::new);
    public static final RegistryObject<Enchantment> BLINDNESS = register("blindness",
            BlindnessEnchantment::new);
    public static final RegistryObject<Enchantment> MERCY = register("mercy",
            MercyEnchantment::new);
    public static final RegistryObject<Enchantment> LUCK = register("luck",
            LuckEnchantment::new);
    public static final RegistryObject<Enchantment> UNLUCK = register("unluck",
            UnluckEnchantment::new);
    public static final RegistryObject<Enchantment> HUNGER = register("hunger",
            HungerEnchantment::new);
    public static final RegistryObject<Enchantment> GLOW = register("glow",
            GlowingEnchantment::new);
    public static final RegistryObject<Enchantment> TOO_LUCK = register("too_luck",
            TooLuckEnchantment::new);
    public static final RegistryObject<Enchantment> TOO_UNLUCK = register("too_unluck",
            TooUnLuckEnchantment::new);
    public static final RegistryObject<Enchantment> PARTYDOWN = register("partydown",
            PartyDownEnchantment::new);
    public static final RegistryObject<Enchantment> RANDOM_EFFECT = register("random_effect",
            RandomEffectEnchantment::new);
    public static final RegistryObject<Enchantment> REVERT_EFFECT = register("revert_effect",
            RevertEffectEnchantment::new);
    public static final RegistryObject<Enchantment> MERGE_EFFECT = register("merge_effect",
            MergeEffectEnchantment::new);
    public static final RegistryObject<Enchantment> SPLIT_EFFECT = register("split_effect",
            SplitEffectEnchantment::new);
    public static final RegistryObject<Enchantment> TURN_WEAPON = register("turn_weapon",
            TurnWeaponEnchantment::new);
    /**
     * Used for registry enchantments
     *
     * @param name Items' registry name
     * @param enchantmentSupplier enchantmentSupplier
     * @param <T>  sth extends Enchantment
     * @return new RegistryObject<Enchantment>
     */
    private static <T extends Enchantment> RegistryObject<T> register(String name, Supplier<T> enchantmentSupplier) {
        return ENCHANTMENTS.register(name, enchantmentSupplier);
    }

}
